From 5b34e3e0dd1cf0b702ec21dd90bacef1a6cbede3 Mon Sep 17 00:00:00 2001 From: robertl Date: Thu, 20 Feb 2003 15:44:04 +0000 Subject: [PATCH] move cache type -> icon recognition into common code. --- defs.h | 4 ++++ magproto.c | 21 +++------------------ util.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/defs.h b/defs.h index 883611df6..c53e5b3fb 100644 --- a/defs.h +++ b/defs.h @@ -247,7 +247,10 @@ typedef struct ff_vecs { typedef struct style_vecs { const char *name; const char *style_buf; + const char *desc; + const char *ext; } style_vecs_t; +extern style_vecs_t style_list[]; typedef struct filter_vecs { filter_init f_init; @@ -318,6 +321,7 @@ int case_ignore_strcmp(const char *s1, const char *s2); void rtrim(char *s); signed int get_tz_offset(void); +const char *get_cache_icon(const waypoint *waypointp); /* * PalmOS records like fixed-point numbers, which should be rounded diff --git a/magproto.c b/magproto.c index 8b16a7922..4d06e9eaf 100644 --- a/magproto.c +++ b/magproto.c @@ -1083,25 +1083,10 @@ mag_waypt_pr(const waypoint *waypointp) icon_token = mag_find_token_from_descr(waypointp->icon_descr); } - /* - * For icons, type overwrites container. So a multi-micro will - * get the icons for "multi". - */ - switch (waypointp->gc_data.container) { - case gc_micro: - icon_token = mag_find_token_from_descr("Micro-Cache"); - break; - } - switch (waypointp->gc_data.type) { - case gt_virtual: - icon_token = mag_find_token_from_descr("Virtual cache"); - break; - case gt_multi: - icon_token = mag_find_token_from_descr("Multi-Cache"); - break; - default: - break; + if (get_cache_icon(waypointp)) { + icon_token = mag_find_token_from_descr(get_cache_icon(waypointp)); } + isrc = waypointp->notes ? waypointp->notes : waypointp->description; owpt = global_opts.synthesize_shortnames ? mkshort(mkshort_handle, isrc) : waypointp->shortname, diff --git a/util.c b/util.c index 5206a80eb..ab927aced 100644 --- a/util.c +++ b/util.c @@ -342,3 +342,33 @@ get_tz_offset(void) return (signed int) difftime(now, later); } } + +/* + * Return a pointer to a constant string that is suitable for icon lookup + * based on geocache attributes. The strings used are those present in + * a GPX file from geocaching.com. Thus we sort of make all the other + * formats do lookups based on these strings. + */ +const char * +get_cache_icon(const waypoint *waypointp) +{ + /* + * For icons, type overwrites container. So a multi-micro will + * get the icons for "multi". + */ + switch (waypointp->gc_data.container) { + case gc_micro: + return "Micro-Cache"; + break; + } + switch (waypointp->gc_data.type) { + case gt_virtual: + return "Virtual cache"; + case gt_multi: + return "Multi-Cache"; + break; + default: + break; + } + return NULL; +} -- 2.30.2